/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: Nov 18, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.gmatrix.toolkit;

import edu.psu.geovista.app.gmatrix.JDfMatrix;
import edu.psu.geovista.app.gmatrix.canvas.DfMatrixCanvas;
import edu.psu.geovista.app.gmatrix.control.DfSelectMgr;

import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MatrixLoggerMgr {
    private static final Logger logger=Logger.getLogger(MatrixLoggerMgr.class.getName());
    /* static{//configure logging
          Level mylevel= Level.ALL;
          ConsoleHandler handler=new ConsoleHandler();
          logger.addHandler(handler);  // 

          logger.setLevel(mylevel);
          handler.setLevel(mylevel );// 

    }*/

    public static void setLevel(Class aclass, Level mylevel){
          Logger logger=Logger.getLogger(aclass.getName());
          //ConsoleHandler handler=new ConsoleHandler();
        Handler[] handlers = logger.getHandlers();
        if(handlers!=null&&handlers.length >0){
            handlers[0].setLevel(mylevel);
        }
        else{
           ConsoleHandler handler=new ConsoleHandler();
           handler.setLevel(mylevel);
           logger.addHandler(handler);

        }
        //addHandler(handler);  // 

          logger.setLevel(mylevel);
          //handler.setLevel(mylevel );// 
       // logger.get
    }


    public static void setting(){
        //setLevel(DfMouseSelectSupport.class,Level.FINE );
       //setLevel(DfMatrixHeader.class,Level.FINE );
         setLevel(JDfMatrix.class,Level.FINE );
         //setLevel(DfMatrixUI.class,Level.FINE );
         //setLevel(DfDendrogram2.class,Level.FINE );
         //setLevel(HorizontalBNode.class,Level.FINE );   // JRowHeadDfTableModel
         setLevel(DfMatrixCanvas.class,Level.FINE );
        setLevel(DfSelectMgr.class,Level.FINE );

        //setLevel(JRowHeadDfTableModel.class,Level.FINE );
    }
     public static void fine(Logger log, String msg){
        if(log.isLoggable(Level.FINE ) ){
            System.out.println(msg);
        }
    }

}
